Components.utils.import("resource://gre/modules/DbTerminal.jsm");


function windowInit()
{
    
    setWindowTitle();
    dDeviceSqlite.onLoad();
    var listbox =  document.getElementById("thelist");
    var statement = dDeviceSqlite.dbConnection.createStatement("\
                  SELECT aName,aPwd,aServiceType,dId FROM td_account where aName = :myVal");
            statement.params.myVal = window.arguments[0];
            //alert(window.arguments[0]);
            while(statement.executeStep()){
                        var tvname = null;
                        var dIds=statement.row.dId;
                       
                        var tvstate = dDeviceSqlite.dbConnection.createStatement("\
                  SELECT dName FROM td_device where dId = :myVal");
                        tvstate.params.myVal = dIds;
                         while(tvstate.executeStep())
                        {
                            tvname = tvstate.row.dName;
                        }
                        var aNames = statement.row.aName; 
                        var aPwds =statement.row.aPwd;
                        var aServiceTypes = statement.row.aServiceType;
                      // alert(aServiceTypes); 
                        if(tvname === window.arguments[1])
                        {
                            var listitem = document.createElement("listitem");
                            var listcell1 = document.createElement("listcell");
                            var listcell2 = document.createElement("listcell");
                            var listcell3 = document.createElement("listcell");
                            var listcell4 = document.createElement("listcell");
                            var listcell5 = document.createElement("listcell");
                            listcell1.setAttribute("label",aNames);
                            listitem.appendChild(listcell1);
                            listcell2.setAttribute("label",aPwds);
                            listitem.appendChild(listcell2);
                            listcell3.setAttribute("label",aServiceTypes);
                            listitem.appendChild(listcell3);
                            listcell4.setAttribute("label",tvname);
                            listitem.appendChild(listcell4);
                            listcell5.setAttribute("label","远程管理");
                            listitem.appendChild(listcell5);
                            listbox.appendChild(listitem);
                        }
                      
                    }
            }
    //createNewTabbox(window.arguments[0]);
    

function setWindowTitle()
{
   
    var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator);
    var enumwindow = windowManager.getEnumerator(null);

    while (enumwindow.hasMoreElements()) {
        var win = enumwindow.getNext().QueryInterface(Components.interfaces.nsIDOMChromeWindow);
        if (win.name === "accountInfo") {
           document.title = "查看" + window.arguments[0].toString() + "账户信息";
            //alert(window.arguments[0].name);
        }
    }
}
//function(){setTimeout(function(){windowInit();},0);}
//window.addEventListener('load', windowInit, false);

window.addEventListener("load", function () {
    setTimeout(function () {
        windowInit();
    }, 1);
});